package com.example.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.project.entity.Activity;
import com.example.project.mapper.ActivityMapper;

/**
 * 活动信息Controller
 *
 * @author changyao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/project/activity")
public class ActivityController
{
    @Autowired
    private ActivityMapper activityMapper;

    /**
     * 查询活动信息列表
     */
    @GetMapping("/list")
    public List<Activity> list()
    {
        QueryWrapper<Activity> queryWrapper=new QueryWrapper<>();
        return activityMapper.selectList(queryWrapper);
    }




    /**
     * 获取活动信息详细信息
     */
    @PostMapping("/detil")
    public Activity getInfo(@RequestBody Activity activity)
    {
        return activityMapper.selectById(activity);
    }


    /**
     * 新增活动信息
     */
    @PostMapping("/add")
    public int add(@RequestBody Activity activity)
    {
        return activityMapper.insert(activity);
    }

    /**
     * 修改活动信息
     */
    @PostMapping("/edit")
    public int edit(@RequestBody Activity activity)
    {
        return activityMapper.updateById(activity);
    }

    /**
     * 删除活动信息
     */
	@PostMapping("/del")
    public int remove(@RequestBody Activity activity)
    {
        return activityMapper.deleteById(activity);
    }
}
